
clear
*import delimited "/Users/melamend.9la/Desktop/ASR Comment Data/outwhite.csv", encoding(ISO-8859-1)
import delimited "/Users/melamend.9la/Desktop/School/Research/UnderReview/ASR Comment Data/outwhite.csv"
destring dnested statusresponses goodresponses income dgood s1 s2 s3 s4 s5 s6 s7 s8 g1 g2 g3 g4 g5 g6 g7 g8 s9 s10 s11 s12 s13 s14 s15 s16 g9 g10 g11 g12 g13 g14 g15 g16, force replace
tab deletelessthan3

* Descriptive statistics in the Appendix
sum s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16 if sublevel==1 & deletelessthan3==0
sum g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11 g12 g13 g14 g15 g16 if sublevel==1 & deletelessthan3==0


* More descriptives
sum dgood dstatus if sublevel==1
sum dgood dstatus if white==0 & sublevel==1
sum dgood dstatus if white==1 & sublevel==1
cor dgood dstatus if sublevel==1
cor dgood dstatus if sublevel==1 & white==1
cor dgood dstatus if sublevel==1 & white==0
scatter dgood dstatus if sublevel==1

* positive d scores mean they favor whites
* regression models in the table
regress dgood dstatus white female liberal education blackfirst statusfirst if sublevel==1 & deletelessthan3==0
regress dstatus dgood white  female liberal education blackfirst statusfirst if sublevel==1 & deletelessthan3==0


*****
* Measurement models
*****

* S1-S8 status evaluations (paired with blacks)
* S9-S16 status evaluations (paired with whites)
* G1-G8 valence (good paired with black)
* G9-G16 valence (good paired with white)
gen black = 1-white
replace s1 = log(s1)
replace s2 = log(s2)
replace s3 = log(s3)
replace s4 = log(s4)
replace s5 = log(s5)
replace s6 = log(s6)
replace s7 = log(s7)
replace s8 = log(s8)
replace s9 = log(s9)
replace s10 = log(s10)
replace s11 = log(s11)
replace s12 = log(s12)
replace s13 = log(s13)
replace s14 = log(s14)
replace s15 = log(s15)
replace s16 = log(s16)
replace g1 = log(g1)
replace g2 = log(g2)
replace g3 = log(g3)
replace g4 = log(g4)
replace g5 = log(g5)
replace g6 = log(g6)
replace g7 = log(g7)
replace g8 = log(g8)
replace g9 = log(g9)
replace g10 = log(g10)
replace g11 = log(g11)
replace g12 = log(g12)
replace g13 = log(g13)
replace g14 = log(g14)
replace g15 = log(g15)
replace g16 = log(g16)


* Status and Valence are different, regardless of race
sem (s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16<- STATUS)(g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11 g12 g13 g14 g15 g16 <-GOOD) if sublevel==1 & deletelessthan3==0, method(mlmv)
estat gof, stats(all)

* Status and valence measure the same thing, regardless of race
sem  (s1 s2 s3 s4 s5 s6 s7 s8 s9 s10 s11 s12 s13 s14 s15 s16 g1 g2 g3 g4 g5 g6 g7 g8 g9 g10 g11 g12 g13 g14 g15 g16 <- VALENCE) if sublevel==1 & deletelessthan3==0, method(mlmv)
estat gof, stats(all)

* Status and valence are different, and depend on race
sem (s1 s2 s3 s4 s5 s6 s7 s8 <- BSTATUS) (s9 s10 s11 s12 s13 s14 s15 s16<- WSTATUS)(g1 g2 g3 g4 g5 g6 g7 g8 <-BGOOD) (g9 g10 g11 g12 g13 g14 g15 g16 <-WGOOD) if sublevel==1 & deletelessthan3==0, method(mlmv)
estat gof, stats(all)

* Status and valence are the same, and depend on race
sem (s1 s2 s3 s4 s5 s6 s7 s8 g1 g2 g3 g4 g5 g6 g7 g8 <- BLACKEVAL) (s9 s10 s11 s12 s13 s14 s15 s16 g9 g10 g11 g12 g13 g14 g15 g16 <- WEVAL) if sublevel==1 & deletelessthan3==0, method(mlmv)
estat gof, stats(all)

***
* Best-fitting is that status and valence are different, but depend on which race is paired

* Sep measurement models by race, not different
sem  (s1 s2 s3 s4 s5 s6 s7 s8 <- BSTATUS) (s9 s10 s11 s12 s13 s14 s15 s16<- WSTATUS) if sublevel==1 & deletelessthan3==0, variance(BSTATUS@1) mean(BSTATUS@0) variance(WSTATUS@1) mean(WSTATUS@0) group(black) ginvariant(none)
estat ginvariant, showpclass(mcoef) class

* THIS IS THE PREFERED MODEL 
sem ( female liberal education blackfirst statusfirst-> BSTATUS) ( female liberal education blackfirst statusfirst-> WSTATUS) (s1 s2 s3 s4 s5 s6 s7 s8 <- BSTATUS) (s9 s10 s11 s12 s13 s14 s15 s16<- WSTATUS) if sublevel==1 & deletelessthan3==0, method(mlmv) group(black) ginvariant(scoef scons)
estat ginvariant, showpclass(mcoef) class
estat gof, stats(all)

